package com.atguigu.bigdata.scala.mytest.chapter07

import scala.collection.mutable.ArrayBuffer

object Test_Array1 {
  def main(args: Array[String]): Unit = {
    val ints: ArrayBuffer[Int] = ArrayBuffer(1,2,3)
    val ints1: ArrayBuffer[Int] = ArrayBuffer(4,5,6)
    //产生新集合
    val ints2: ArrayBuffer[Int] = ints ++ ints1
    println(ints2)
    println(ints eq ints2)
    //不产生新集合
    val ints3: ArrayBuffer[Int] = ints ++= ints1
    println(ints3)
    println(ints eq ints3)

    val ints4 = Array(1,2,3)
    val ints5 = Array(4,5,6)
    //合并数组
    val ints6: Array[Int] = Array.concat(ints4,ints5)
    ints6.foreach(println)
    println("==========================")
    //创建二维数组
    val array: Array[Array[Int]] = Array.ofDim[Int](2,3)
    array.foreach(ls => ls.foreach(ls =>{print(ls)}))

    //创建指定范围内的数组
    val ints7: Array[Int] = Array.range(3,5)
    ints7.foreach(println)//4

    println("==========================")
    // 创建并填充指定数量的数组
    val ints8: Array[String] = Array.fill[String](3)("a")
    ints8.foreach(println)
  }
}
